{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "a42076a4",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name: xiaohongzhou\n",
      "age: 23\n",
      "job: student\n",
      "salary: 10000000\n",
      "------INFOxiaohongzhou------\n",
      "name: xiaohongzhou\n",
      "age: 23\n",
      "job: student\n",
      "salary: 10000000\n",
      "['2021', '10', '27']\n",
      "10\n"
     ]
    }
   ],
   "source": [
    "# author: hongzhou\n",
    "# week05: 数据结构之列表\n",
    "\n",
    "# 用户输入方法: input()\n",
    "# 回顾上节内容: 登录系统（while循环、input输入）\n",
    "# 本节: 打印（print）输出的一般方法\n",
    "\n",
    "name = input(\"name: \")\n",
    "age = input(\"age: \")\n",
    "job = input(\"job: \")\n",
    "salary = input(\"salary: \")\n",
    "\n",
    "# 注释来写内容存到字符串中\n",
    "# 知识点1：字符串拼接 用 + 让打印结果更直观\n",
    "info ='''------INFO'''+ name+'''------'''+'''\n",
    "name: '''+name+'''\n",
    "age: '''+age+'''\n",
    "job: '''+job+'''\n",
    "salary: '''+salary\n",
    "print(info)\n",
    "\n",
    "\n",
    "# or\n",
    "# 知识点2：%s占位符可以把“+”符号 省略，比较直观的展示变量内容\n",
    "#        缺点：如果变量过多, 需要考量顺序和出现次数\n",
    "# info = '''------INFO %s ------\n",
    "# name:%s\n",
    "# age:%s\n",
    "# job:%s\n",
    "# salary:%s '''%(name,name,age,job,salary)\n",
    "# print(info)\n",
    "\n",
    "\n",
    "# or\n",
    "# 知识点3： .format() 比起%s 更适合较多变量的打印，不需要考量顺序和出现次数\n",
    "#          例如： url的拼接 (https：// + 域名 + endpoint)\n",
    "# info1 = '''------INFO {HTML_name}------\n",
    "# name: {HTML_name}\n",
    "# age: {HTML_age}\n",
    "# job: {HTML_job}\n",
    "# salary: {HTML_salary}'''.format(HTML_name=name, HTML_age=age, HTML_job=job, HTML_salary=salary)\n",
    "# print(info)\n",
    "\n",
    "\n",
    "# or\n",
    "# %d 字符串应该输入的是数字，而不是变量/\n",
    "\n",
    "\n",
    "# 假如你要求用户以2021-10-27 格式输入\n",
    "user_input_time = \"2021-10-27\"\n",
    "# 字符串拆分，方法 split 拆分完的结果是一个 列表\n",
    "print(user_input_time.split('-'))\n",
    "print(user_input_time.split('-')[1])\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
